package com.fzb.forum4j.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.stereotype.Repository;

import com.fzb.forum4j.dao.api.IWebSiteDao;
import com.fzb.forum4j.po.WebSite;
import com.sun.xml.internal.stream.Entity;
@Repository("webSiteDaoImpl")
public class WebSiteDaoImpl extends HibBaseImpl<WebSite> implements IWebSiteDao {

	@SuppressWarnings("unchecked")
	@Override
	public Map<String, String> initWebSite() {
		List<Object[]> list=(List<Object[]>)getSession().createQuery("select t.name,t.value from WebSite t where t.status=true").list();
		System.out.println(list);
		Map<String, String> init=new HashMap<String, String>();
		for (Object[] o : list) {
			init.put(o[0].toString(), (String) o[1]);
		}
		return init;
	}

	@Override
	public List<Map<String,Object>> loadWebSite(List<String> names) {
		return getSession().createQuery("select  new map(t.siteId as id,t.name as name,t.value as value) from WebSite t where t.name in :name").setParameterList("name", names).list();
		 
	}
 
 
 

}
 